<!--
 * @Author: mengqingchen 
 * @Date: 2022-11-08 11:20:21
 * @LastEditors: mengqingchen 
 * @LastEditTime: 2022-11-09 16:52:42
 * @FilePath: \soso-mall-pc\src\icons\index.vue
 * @Description: 
-->
<template>
  <svg aria-hidden="true" class="svg-icon" @mouseenter="normal = hover">
    <use :href="symbolId" :fill="normal" />
  </svg>
</template>

<script>
import { defineComponent, computed } from 'vue'

export default defineComponent({
  name: 'SvgIcon',
  props: {
    prefix: {
      type: String,
      default: 'icon'
    },
    name: {
      type: String,
      required: true
    },
    color: {
      type: String,
      default: '#333'
    },
    hover: {
      type: String,
      default: ''
    }
  },
  setup(props) {
    const symbolId = computed(() => `#${props.prefix}-${props.name}`)

    const normal = ref('')
    onMounted(() => {
      normal.value = props.color
    })
    return { symbolId }
  }
})
</script>
<style lang="scss">
.svg-icon {
  width: 1em;
  height: 1em;
  overflow: hidden;
  vertical-align: -0.15em;
  fill: currentcolor;
}
</style>
